package CountDownLatchTest;

import java.util.concurrent.BlockingDeque;
import java.util.concurrent.CyclicBarrier;

/**
 * Created by dycong on 2017/4/5.
 */
public class Work implements Runnable{
    int row;
    int total;
    int[][] ints;
    BlockingDeque deque;
    CyclicBarrier barrier;
    public Work(int i, int[][] in, BlockingDeque blockingDeque,CyclicBarrier cyclicBarrier) {
        row = i;
        ints=in;
        deque=blockingDeque;
        barrier=cyclicBarrier;
    }

    @Override
    public void run() {
        for (int i = 0; i < 10; i++) {
            total += ints[row][i];
        }
        deque.push(total);
        try {
            barrier.await();
        } catch (Exception e) {

        }
        System.out.println("merge ok");
        System.out.println(total);
    }
}
